import cv2
import numpy as np
import time
width=400
height=400
r=20
x=r+20
y=r+20
x_v=y_v=16

while(cv2.waitKey(1)==-1):
    if x>width-r or x<r:
        x_v*=-1
    if y>height-r or y<r:
        y_v*=-1
    x+=x_v
    y+=y_v
    img=np.ones((width,height,3),np.uint8)*255
    img=cv2.circle(img,(x,y),r,(255,0,0),-1)
    cv2.imshow("img",img)
    time.sleep(1)
cv2.destroyAllWindows()